<?php
/* @var $this OperationController|TaskController|RoleController */
/* @var $item CAuthItem */
/* @var $ancestorDp AuthItemDataProvider */
/* @var $descendantDp AuthItemDataProvider */
/* @var $formModel AddAuthItemForm */
/* @var $form TbActiveForm */
/* @var $childOptions array */

$createUrl = $this->createUrl('create');
$indexUrl = $this->createUrl('index');
$typeText = $this->capitalize($this->getTypeText(true));
$this->breadcrumbs = array(
    $this->capitalize($this->getTypeText(true)) => array('index'),
		$item->description => array('view', 'name' => $item->name),
    Yii::t('AuthModule.main', '配置权限'),
);
?>

<div class="row">
	<div class="col-lg-12">
		<div class="panel panel-danger">
			<div class="panel-heading">
				<h4><?php echo "配置".$typeText."：".CHtml::encode($item->description); ?></h4>
				
				<div class="options">
				<a href="<?php echo $indexUrl;?>"><i class="icon-th-list">返回<?php echo $typeText;?>列表</i></a>
				<a href="<?php echo $createUrl;?>"><i class="icon-cogs">创建新的<?php echo $typeText;?></i></a>
				
				
			    </div>
			</div>
			<div class="panel-body">

				<?php $this->widget(
				    'zii.widgets.CDetailView',
				    array(
				        'data' => $item,
				        'attributes' => array(
				            array(
				                'name' => 'name',
				                'label' => Yii::t('AuthModule.main', 'System name'),
				            ),
				            array(
				                'name' => 'description',
				                'label' => Yii::t('AuthModule.main', 'Description'),
				            ),
				            
				            array(
				                'name' => 'bizrule',
				                'label' => Yii::t('AuthModule.main', 'Business rule'),
				            ),
				            array(
				                'name' => 'data',
				                'label' => Yii::t('AuthModule.main', 'Data'),
				            ),
				           
				        ),
				    )
				); ?>
				<hr/>
				<div class="panel panel-primary">
			<div class="panel-body">
		        <h3>
		            <?php echo Yii::t('AuthModule.main', 'Ancestors'); ?>
		            <small><?php echo Yii::t('AuthModule.main', 'Permissions that inherit this item'); ?></small>
		        </h3>
		
		        <?php $this->widget(
		            'bootstrap.widgets.BsGridView',
		            array(
		                'type' => 'striped condensed hover',
		                'dataProvider' => $ancestorDp,
		                'emptyText' => Yii::t('AuthModule.main', 'This item does not have any ancestors.'),
		                'template' => "{items}",
		                'hideHeader' => true,
		                'columns' => array(
		                    array(
		                        'class' => 'AuthItemDescriptionColumn',
		                        'itemName' => $item->name,
		                    ),
		                    array(
		                        'class' => 'AuthItemTypeColumn',
		                        'itemName' => $item->name,
		                    ),
		                    array(
		                        'class' => 'AuthItemRemoveColumn',
		                        'itemName' => $item->name,
		                    ),
		                ),
		            )
		        ); ?>

   			 </div>
    </div>
				<div class="panel panel-primary">
					<div class="panel-body">
				        <h3>
				            <?php echo Yii::t('AuthModule.main', 'Descendants'); ?>
				            <small><?php echo Yii::t('AuthModule.main', 'Permissions granted by this item'); ?></small>
				        </h3>
				
				        <?php $this->widget(
				            'bootstrap.widgets.BsGridView',
				            array(
				                'type' => 'striped condensed hover',
				                'dataProvider' => $descendantDp,
				                'emptyText' => Yii::t('AuthModule.main', 'This item does not have any descendants.'),
				                'hideHeader' => true,
				                'template' => "{items}",
				                'columns' => array(
				                    array(
				                        'class' => 'AuthItemDescriptionColumn',
				                        'itemName' => $item->name,
				                    ),
				                    array(
				                        'class' => 'AuthItemTypeColumn',
				                        'itemName' => $item->name,
				                    ),
				                    array(
				                        'class' => 'AuthItemRemoveColumn',
				                        'itemName' => $item->name,
				                    ),
				                ),
				            )
				        ); ?>
		
				</div>
			</div>
			
			<div class="panel panel-primary">
			<div class="panel-body">


        <?php if (!empty($childOptions)): ?>

            <h4><?php echo Yii::t('AuthModule.main', 'Add child'); ?></h4>

            <?php $form = $this->beginWidget(
                'bootstrap.widgets.BsActiveForm',
                array(
                    'layout' => BSHtml::FORM_LAYOUT_INLINE,
                )
            ); ?>

            <?php echo $form->dropDownListControlGroup($formModel, 'items', $childOptions, array('label' => false)); ?>

            <?php echo BSHtml::submitButton(
                Yii::t('AuthModule.main', 'Add'),
                array(
                    'color' => BSHtml::BUTTON_COLOR_PRIMARY,
                )
            ); ?>

            <?php $this->endWidget(); ?>

        <?php endif; ?>

    </div>
    </div>
			
			</div> <!-- end body -->

		</div> <!-- end pannel -->

	</div>
</div>

